package com.qf.oa_system.service.impl;

import com.qf.oa_system.entity.Classmaster;
import com.qf.oa_system.mapper.ClassmasterDao;
import com.qf.oa_system.service.ClassmasterService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * ?????α(Classmaster)表服务实现类
 *
 * @author makejava
 * @since 2020-06-03 20:26:21
 */
@Service("classmasterService")
public class ClassmasterServiceImpl implements ClassmasterService {
    @Resource
    private ClassmasterDao classmasterDao;

    /**
     * 通过ID查询单条数据
     *
     * @param masId 主键
     * @return 实例对象
     */
    @Override
    public Classmaster queryById(Integer masId) {
        return this.classmasterDao.queryById(masId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Classmaster> queryAllByLimit(int offset, int limit) {
        return this.classmasterDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param classmaster 实例对象
     * @return 实例对象
     */
    @Override
    public Classmaster insert(Classmaster classmaster) {
        this.classmasterDao.insert(classmaster);
        return classmaster;
    }

    /**
     * 修改数据
     *
     * @param classmaster 实例对象
     * @return 实例对象
     */
    @Override
    public Classmaster update(Classmaster classmaster) {
        this.classmasterDao.update(classmaster);
        return this.queryById(classmaster.getMasId());
    }

    /**
     * 通过主键删除数据
     *
     * @param masId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer masId) {
        return this.classmasterDao.deleteById(masId) > 0;
    }

    @Override
    public Classmaster queryClassmasterByUserId(int userId) {
        Classmaster classmaster = classmasterDao.queryClassmasterByUserId(userId);
        return classmaster;
    }
}